package com.company.cloud.common.swagger2;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
@ConfigurationProperties("saas.swagger")
public class SwaggerProperties {

	/** 是否开启swagger **/
	private Boolean enabled;
	/** 标题 **/
	private String title = "";
	/** 描述 **/
	private String description = "";
	/** 版本 **/
	private String version = "";
	/** 许可证 **/
	private String license = "";
	/** 许可证URL **/
	private String licenseUrl = "";
	/** 服务条款URL **/
	private String termsOfServiceUrl = "";
	/** 联系人 **/
	private Contact contact = new Contact();

	/** swagger会解析的包路径 **/
	private String basePackage = "";

	/** swagger会解析的url规则 **/
	private List<String> basePath = new ArrayList<>();
	
	/** 在basePath基础上需要排除的url规则 **/
	private List<String> excludePath = new ArrayList<>();
	
	/**pathMapping*/
	private String pathMapping="";

	/** 分组文档 **/
	private Map<String, DocketInfo> docket = new LinkedHashMap<String, DocketInfo>();

	/** host信息 **/
	private String host = "";

	/** 全局参数配置 **/
	private List<GlobalOperationParameter> globalOperationParameters;

	@Setter
	@Getter
	public static class GlobalOperationParameter {
		/** 参数名 **/
		private String name;

		/** 描述信息 **/
		private String description;

		/** 指定参数类型 **/
		private String modelRef;

		/** 参数放在哪个地方:header,query,path,body.form **/
		private String parameterType;

		/** 参数是否必须传 **/
		private String required;
	}

	@Data
	public static class DocketInfo {
		/** 标题 **/
		private String title = "";
		/** 描述 **/
		private String description = "";
		/** 版本 **/
		private String version = "";
		/** 许可证 **/
		private String license = "";
		/** 许可证URL **/
		private String licenseUrl = "";
		/** 服务条款URL **/
		private String termsOfServiceUrl = "";

		private Contact contact = new Contact();

		/** swagger会解析的包路径 **/
		private String basePackage = "";

		/** swagger会解析的url规则 **/
		private List<String> basePath = new ArrayList<String>();
		/** 在basePath基础上需要排除的url规则 **/
		private List<String> excludePath = new ArrayList<String>();

		private List<GlobalOperationParameter> globalOperationParameters;
	}

	@Data
	public static class Contact {
		/** 联系人 **/
		private String name = "";
		/** 联系人url **/
		private String url = "";
		/** 联系人email **/
		private String email = "";
	}
}
